package com.config.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.config.dao.EquMoldDao;
import com.config.dao.EquipmentDao;
import com.config.entity.Equipment;

@Service(value="equipmentService")
public class EquipmentServiceImpl implements EquipmentService{

	@Resource(name = "equipmentDao")
	private EquipmentDao equipmentDao;
	@Resource(name = "equMoldDao")
	private EquMoldDao moldDao;
	
	@Override
	public void save(Equipment entity) {
		equipmentDao.save(entity);
	}

	@Override
	public void delete(int id) {
		equipmentDao.delete(id);
	}

	@Override
	public void update(Equipment entity) {
		equipmentDao.update(entity);
	}

	@Override
	public Equipment getEquipment(int id) {
		return equipmentDao.get(id);
	}
	
	@Override
	public List<Equipment> listByLine(Integer lineId) {
		return equipmentDao.listByLine(lineId);
	}

	@Override
	public List<Equipment> findByLine(Integer lineId,int start, int limit) {
		List<Equipment> list=equipmentDao.findByLine(lineId, start, limit);
		for(Equipment e:list){
			e.setType(moldDao.get(e.getEquMoldId()).getEquType());
		}
		return list;
	}
	
	@Override
	public int countByLine(Integer lineId) {
		return equipmentDao.countByLine(lineId);
	}

	@Override
	public List<Equipment> findByEquModlId(int equMoldId) {
		return equipmentDao.findByEquModlId(equMoldId);
	}

	@Override
	public Equipment getByEquNo(String equNo) {
		return equipmentDao.getByEquNo(equNo);
	}

}
